﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;
using System.Web.Mvc;

namespace HtmlContent.Models
{

    [MetadataType(typeof(Page_Validation))]
    public partial class Page
    {
        public Guid HtmlPageId { get; set; }
        public Guid HtmlContentId { get; set; }
        public string ContentText { get; set; }
    }

    public class Page_Validation
    {
        [HiddenInput(DisplayValue = false)]
        public Guid PageId { get; set; }

        [HiddenInput(DisplayValue = false)]
        public Guid BusinessUnitId { get; set; }

        [HiddenInput(DisplayValue = false)]
        public Guid HtmlPageId { get; set; }

        [HiddenInput(DisplayValue = false)]
        public Guid HtmlContentId { get; set; }

        [Required(ErrorMessage = "A Title for the page is required.")]
        [Display(Name = "Page Title")]
        [StringLength(127, ErrorMessage = "Title cannot be more than 127 characters.")]
        public string Title { get; set; }

        [Required(ErrorMessage = "Page Name is required.")]
        [Display(Name = "Page Name (URL)")]
        [StringLength(127, ErrorMessage = "Page name cannot be more than 127 characters.")]
        public string PageName { get; set; }

        [Display(Name = "Meta Keywords")]
        [StringLength(255, ErrorMessage = "Meta Keywords cannot be more than 255 characters.")]
        [DataType(DataType.MultilineText)]
        public string MetaKeywords { get; set; }

        [Display(Name = "Meta Description")]
        [StringLength(255, ErrorMessage = "Meta description cannot be more than 255 characters.")]
        [DataType(DataType.MultilineText)]
        public string MetaDescription { get; set; }

        [Required(ErrorMessage = "You have to specify if this Page is included on Main Menu.")]
        [StringLength(1, ErrorMessage = "Can be only 1 character")]
        [Display(Name = "On Main Menu?")]
        public string OnMainMenuYN { get; set; }

        [Required(ErrorMessage = "You have to select who can view this page.")]
        [Display(Name="Permission")]
        public Guid PermissionId { get; set; }

        [Required]
        [Display(Name = "Show Title?")]
        public string ShowTitleYN { get; set; }

        [DataType(DataType.MultilineText)]
        [Display(Name = "Content")]
        [AllowHtml]
        public string ContentText { get; set; }

        [ScaffoldColumn(false)]
        public string IsDroppedYN { get; set; }

        [ScaffoldColumn(false)]
        public DateTime CreateDT { get; set; }

        [ScaffoldColumn(false)]
        public Guid CreatedById { get; set; }

        [ScaffoldColumn(false)]
        public string CreatedByName { get; set; }

        [ScaffoldColumn(false)]
        public DateTime ModifiedDT { get; set; }

        [ScaffoldColumn(false)]
        public Guid ModifiedById { get; set; }

        [ScaffoldColumn(false)]
        public string ModifiedByName { get; set; }
    }

    [MetadataType(typeof(Container_Validation))]
    public partial class Container
    {
        public string SortSequence
        {
            get
            {
                return String.Format("{0:3d}{1:3d}", NestLevel, Sequence);
            }
        }
    }

    public class Container_Validation
    {
        [HiddenInput(DisplayValue = false)]
        public Guid ContainerId { get; set; }

        [HiddenInput(DisplayValue = false)]
        public Guid PluginId { get; set; }

        [HiddenInput(DisplayValue = false)]
        public Guid ContentId { get; set; }

        [HiddenInput(DisplayValue = false)]
        public int NestLevel { get; set; }

        [HiddenInput(DisplayValue = false)]
        public int Sequence { get; set; }

        [Required(ErrorMessage = "Container name is required.")]
        [Display(Name = "Name")]
        [StringLength(127, ErrorMessage = "Container name cannot be more than 127 characters.")]
        [DataType(DataType.Text)]
        public string ContainerName { get; set; }

        [Required(ErrorMessage = "Container Type is required.")]
        [Display(Name = "Type")]
        [DataType(DataType.Text)]
        public string ContainerType { get; set; }

        [Display(Name = "Title")]
        [DataType(DataType.Text)]
        public string Title { get; set; }

        [Display(Name = "Width (0=Free Flowing)")]
        public int Width { get; set; }

        [Display(Name = "Show Chrome?")]
        public string ShowChromeYN { get; set; }
    }

}